package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeSimpleResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 区域相关接口")
public class ServeController {
    @Resource
    private IServeService serveService;

    /**
     * 首页服务分类
     * @param regionId
     * @return
     */
    @GetMapping("/firstPageServeList")
    @ApiOperation("首页服务分类及项目")
    public List<ServeCategoryResDTO> firstPageServeList(Long regionId) {
        return serveService.firstPageServeList(regionId);
    }

    /**
     * 热门推荐
     * @param regionId
     * @return
     */
    @GetMapping("/hotServeList")
    @ApiOperation("精选推荐")
    public List<ServeAggregationSimpleResDTO> hotServeList(Long regionId) {
        return serveService.hotServeList(regionId);
    }

    /**
     * 查询服务详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("查询服务详情")
    public ServeAggregationSimpleResDTO findById(@PathVariable("id") Long id) {
        return serveService.findById(id);
    }

    /**
     * 查询全部分类
     * @param regionId
     * @return
     */
    @GetMapping("/serveTypeList")
    @ApiOperation("查询当前区域下上架服务对应的分类")
    public List<ServeAggregationTypeSimpleResDTO> serveTypeList(Long regionId) {
        return serveService.serveTypeList(regionId);
    }

    /**
     * 服务搜索
     * @param cityCode
     * @param keyword
     * @param serveTypeId
     * @return
     */
    @GetMapping("/search")
    @ApiOperation("服务搜索")
    public  List<ServeSimpleResDTO> search(String cityCode, String keyword, Long serveTypeId) {
        return serveService.search(cityCode, keyword, serveTypeId);
    }
}